package com.io.nio.mappedByteBuffer;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.CharBuffer;
import java.nio.IntBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class Demo3 {

	static int length = 0x8F;

	public static void main(String[] args) throws IOException {
		MappedByteBuffer out = new RandomAccessFile("nio3.txt", "rw")
				.getChannel()
				.map(FileChannel.MapMode.READ_WRITE, 0, length + 1);
		IntBuffer ib = out.asIntBuffer();
		for (int i = 0; i < length/4; i++) {
			ib.put(i);
		}
		System.out.println("========");
		ib.rewind();
		while (ib.hasRemaining()) {
			System.out.println(ib.get());
		}
	}

}
